import os.path
from flask import current_app
from transformers import BertTokenizer, BertModel
import torch.cuda

class Config:
    # 定义设备
    DEVICE = 'cuda' if torch.cuda.is_available() else 'cpu'

    """Unit相关配置"""
    # api_key
    client_id = "qpy98GFVYMatMmGsb8Uzin7W"
    # sercret_key
    client_secret = "wvhsu8bbamdimnNb1xtk7rpGAKKRAt2W"
    # 机器人ID
    service_id = "S118814"
    #获取access_token的URl
    access_token = "https://aip.baidubce.com/oauth/2.0/token?grant_type=client_credentials"
    #请求回复的URL
    unit_reply_url = "https://aip.baidubce.com/rpc/2.0/unit/service/v3/chat"

    """Neo4j相关配置"""
    NEO4J_CONFIG = {
        "uri" : "bolt://localhost:7687",
        "auth" : ("neo4j", "123456"),
        "encrypted" : False
    }

    """rnn模型配置"""
    #输入层
    INPUT_SIZE = 768
    #隐藏层
    HIDDEN_SIZE = 128
    #类别数量
    N_CATEGORIES = 2
    #迭代次数
    n_iters = 50000
    #迭代1000次
    plot_entry = 1000
    #学习率
    LEARNING_RATE = 0.005

    def __init__(self):
        #定义目录路径
        self.reviewed_path = os.path.join(current_app.root_path, "data", "reviewed")
        # TRAIN_DATA_PATH rnn模型训练和验证数据
        self.rnn_train_data_path = os.path.join(current_app.root_path, "application\\data\\model_train", "train_data.csv")
        #BERT_TOKENIZER  获取对应的字符映射，把中文的每个字映射成一个数字
        self.bert_tokenizer = BertTokenizer.from_pretrained(os.path.join(current_app.root_path, "application" , "bert-base-chinese"))
        #加载BERT模型
        self.bert_model = BertModel.from_pretrained(os.path.join(current_app.root_path, "application" ,"bert-base-chinese"))
        # rnn模型保存路径
        self.rnn_model_save_path = os.path.join(current_app.root_path,"application\save_model","bert_rnn.pth")




